﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DataAccessLayer
{
    public class DataBaseConnector
    {
        private static SqlConnection _connector;

        public static SqlConnection Connector
        {
            get
            {
                if (_connector == null)
                {
                    _connector = getConnection();
                } 
                return DataBaseConnector._connector;
            }
            set { DataBaseConnector._connector = value; }
        }

        private static SqlConnection getConnection()
        {
            try
            {
                SqlConnection cn = new SqlConnection();
                return cn;
            }
            catch (SqlException se)
            {
                throw new Exception("Exception in DataBaseConnector/getConnection()", se.InnerException);
            }
        }
    }
}
